package moe.cat.com.moelight;

import android.Manifest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.tbruyelle.rxpermissions2.RxPermissions;

import moe.cat.com.moelight.Manger.Flashlight;
import moe.cat.com.moelight.Utils.ApplicationPermissions;
import moe.cat.com.moelight.Utils.LogHelper;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button button;

    private Button exits;
    private Button open;
    private Button close;





    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.button);
        open = (Button) findViewById(R.id.open);
        close = (Button) findViewById(R.id.close);

        exits = (Button) findViewById(R.id.exits);
        exits.setOnClickListener(this);
        button.setOnClickListener(this);
        open.setOnClickListener(this);
        close.setOnClickListener(this);

        LogHelper.PrintLog(Manifest.permission.CAMERA);
    }

    @Override
    public void onClick(View view) {
        switch (  view.getId()){

            case R.id.button:
                LogHelper.PrintLog("点击button");

                ApplicationPermissions.Camera(this);
                LogHelper.PrintLog(   ApplicationPermissions.CameraExits(this));
                break;
            case R.id.exits:
                LogHelper.PrintLog("点击Ext");
                LogHelper.PrintLog(   ApplicationPermissions.CameraExits(this));
                break;
            case R.id.open:
                Flashlight.OpenFlashlight(this,true);
                break;
            case R.id.close:
                Flashlight.OpenFlashlight(this,false);
                break;
        }
    }
}
